home *** CD-ROM | disk | FTP | other *** search
/ 100 Plus Great Games 2 / 100PLUSV2.BIN / games / MazeCraze.dxr / 00005_Ball Behavior.ls < prev    next >
Encoding:
Text File  |  2002-01-25  |  9.5 KB  |  301 lines

  1. property spriteNum, pMyAngle, h, v, pBalloonDirection, pBalloonSpeed, pLocH, pLocV, pBalloonDistance, pBalloonRotation, pWait4Step, pBalloonAlive, pBlendUp, pBlendDown, pFrame, pLightingH, pLightingV, pTemp, pBlink, pTimePop
  2. global gLevel, gShocked, gLifePoints, gPaused, secs, mins
  3.  
  4. on beginSprite me
  5.   pTemp = 1
  6.   pBlink = 25
  7.   pTimePop = 0
  8.   pLightingH = 0
  9.   pLightingV = 0
  10.   pFrame = 1
  11.   pBalloonAlive = 1
  12.   pLocH = sprite(spriteNum).locH
  13.   pLocV = sprite(spriteNum).locV
  14.   sprite(spriteNum).blend = 100
  15.   pBalloonSpeed = 0
  16.   pBalloonDirection = 0.0
  17.   pBalloonDistance = 0.0
  18.   pBalloonRotation = 0.0
  19.   startTimer()
  20. end
  21.  
  22. on exitFrame me
  23.   if pBalloonAlive = 1 then
  24.     pBalloonDistance = getDistance(sprite(spriteNum).locH, sprite(spriteNum).locV, mouseH(), mouseV())
  25.     if pBalloonDistance > 160 then
  26.       pBalloonSpeed = 0.5
  27.       pBalloonDirection = getAngle(sprite(spriteNum).locH, sprite(spriteNum).locV, mouseH(), mouseV())
  28.     else
  29.       pBalloonDistance = getDistance(sprite(spriteNum).locH, sprite(spriteNum).locV, mouseH(), mouseV())
  30.       pBalloonSpeed = (180 - pBalloonDistance) / 40.0
  31.       pBalloonDirection = getAngle(sprite(spriteNum).locH, sprite(spriteNum).locV, mouseH(), mouseV())
  32.     end if
  33.     pBalloonRotation = 360 - getAngle(mouseH(), mouseV(), sprite(spriteNum).locH, sprite(spriteNum).locV)
  34.     sprite(spriteNum).rotation = pBalloonRotation
  35.     Shocked()
  36.     BalloonMove()
  37.     AnimateBalloon()
  38.     Check4Win()
  39.   end if
  40. end
  41.  
  42. on BalloonMove
  43.   pMyAngle = pBalloonDirection * PI / 180.0
  44.   h = sin(pMyAngle) * pBalloonSpeed
  45.   v = cos(pMyAngle) * pBalloonSpeed
  46.   pLocH = pLocH + h
  47.   pLocV = pLocV + v
  48.   sprite(15).loc = point(pLocH, pLocV)
  49.   updateStage()
  50.   ObjectCollision()
  51.   sprite(spriteNum).loc = point(pLocH, pLocV)
  52.   sprite(19).loc = point(pLocH + pLightingH, pLocV + pLightingV)
  53. end
  54.  
  55. on Shocked
  56.   if gShocked = 1 then
  57.     if gLifePoints <= 0 then
  58.       pBalloonAlive = 0
  59.       gPaused = 1
  60.       member("gameOverText").text = "Give it another try!"
  61.       if secs < 10 then
  62.         member("TimeLeftText").text = "Elapsed Time:" && string(mins) & ":0" & string(secs)
  63.       else
  64.         member("TimeLeftText").text = "Elapsed Time:" && string(mins) & ":" & string(secs)
  65.       end if
  66.       if soundBusy(5) then
  67.         sound(5).stop()
  68.       end if
  69.       puppetSound(6, "gameoverSound")
  70.       cursor(-1)
  71.       go(20)
  72.     end if
  73.     if pTimePop < the timer then
  74.       sprite(spriteNum).blend = 100
  75.       sprite(19).blend = 100
  76.       pBlink = pBlink - 1
  77.       pTimePop = the timer + pBlink
  78.     else
  79.       sprite(spriteNum).blend = 40
  80.       sprite(19).blend = 40
  81.     end if
  82.     if pBlink <= 0 then
  83.       gShocked = 0
  84.       sprite(spriteNum).blend = 100
  85.       sprite(19).blend = 100
  86.     end if
  87.   end if
  88. end
  89.  
  90. on AnimateBalloon
  91.   if (pBalloonDistance < 160) and (pBalloonDistance >= 145) then
  92.     if sprite(spriteNum).member.name <> "Balloon0009" then
  93.       sprite(spriteNum).member = "Balloon0009"
  94.       sound(5).volume = 30
  95.     end if
  96.   else
  97.     if (pBalloonDistance < 145) and (pBalloonDistance >= 130) then
  98.       if sprite(spriteNum).member.name <> "Balloon0008" then
  99.         sprite(spriteNum).member = "Balloon0008"
  100.         sound(5).volume = 55
  101.       end if
  102.     else
  103.       if (pBalloonDistance < 130) and (pBalloonDistance >= 115) then
  104.         if sprite(spriteNum).member.name <> "Balloon0007" then
  105.           sprite(spriteNum).member = "Balloon0007"
  106.           sound(5).volume = 80
  107.         end if
  108.       else
  109.         if (pBalloonDistance < 115) and (pBalloonDistance >= 100) then
  110.           if sprite(spriteNum).member.name <> "Balloon0006" then
  111.             sprite(spriteNum).member = "Balloon0006"
  112.             sound(5).volume = 105
  113.           end if
  114.         else
  115.           if (pBalloonDistance < 100) and (pBalloonDistance >= 85) then
  116.             if sprite(spriteNum).member.name <> "Balloon0005" then
  117.               sprite(spriteNum).member = "Balloon0005"
  118.               sound(5).volume = 130
  119.             end if
  120.           else
  121.             if (pBalloonDistance < 85) and (pBalloonDistance >= 70) then
  122.               if sprite(spriteNum).member.name <> "Balloon0004" then
  123.                 sprite(spriteNum).member = "Balloon0004"
  124.                 sound(5).volume = 155
  125.               end if
  126.             else
  127.               if (pBalloonDistance < 70) and (pBalloonDistance >= 55) then
  128.                 if sprite(spriteNum).member.name <> "Balloon0003" then
  129.                   sprite(spriteNum).member = "Balloon0003"
  130.                   sound(5).volume = 180
  131.                 end if
  132.               else
  133.                 if (pBalloonDistance < 55) and (pBalloonDistance >= 40) then
  134.                   if sprite(spriteNum).member.name <> "Balloon0002" then
  135.                     sprite(spriteNum).member = "Balloon0002"
  136.                     sound(5).volume = 205
  137.                   end if
  138.                 else
  139.                   if (pBalloonDistance < 40) and (pBalloonDistance >= 25) then
  140.                     if sprite(spriteNum).member.name <> "Balloon0001" then
  141.                       sprite(spriteNum).member = "Balloon0001"
  142.                       sound(5).volume = 230
  143.                     end if
  144.                   else
  145.                     if pBalloonDistance < 25 then
  146.                       if sprite(spriteNum).member.name <> "Balloon0000" then
  147.                         sprite(spriteNum).member = "Balloon0000"
  148.                         sound(5).volume = 255
  149.                       end if
  150.                     end if
  151.                   end if
  152.                 end if
  153.               end if
  154.             end if
  155.           end if
  156.         end if
  157.       end if
  158.     end if
  159.   end if
  160.   if sprite(spriteNum).locV <= 55 then
  161.     if pLightingV <> 4 then
  162.       pLightingV = 4
  163.     end if
  164.   else
  165.     if (sprite(spriteNum).locV > 55) and (sprite(spriteNum).locV <= 110) then
  166.       if pLightingV <> 3 then
  167.         pLightingV = 3
  168.       end if
  169.     else
  170.       if (sprite(spriteNum).locV > 110) and (sprite(spriteNum).locV <= 165) then
  171.         if pLightingV <> 2 then
  172.           pLightingV = 2
  173.         end if
  174.       else
  175.         if (sprite(spriteNum).locV > 165) and (sprite(spriteNum).locV <= 220) then
  176.           if pLightingV <> 1 then
  177.             pLightingV = 1
  178.           end if
  179.         else
  180.           if (sprite(spriteNum).locV > 220) and (sprite(spriteNum).locV <= 275) then
  181.             if pLightingV <> 0 then
  182.               pLightingV = 0
  183.             end if
  184.           else
  185.             if (sprite(spriteNum).locV > 275) and (sprite(spriteNum).locV <= 335) then
  186.               if pLightingV <> -1 then
  187.                 pLightingV = -1
  188.               end if
  189.             else
  190.               if (sprite(spriteNum).locV > 335) and (sprite(spriteNum).locV <= 400) then
  191.                 if pLightingV <> -2 then
  192.                   pLightingV = -2
  193.                 end if
  194.               else
  195.                 if sprite(spriteNum).locV > 400 then
  196.                   if pLightingV <> -3 then
  197.                     pLightingV = -3
  198.                   end if
  199.                 end if
  200.               end if
  201.             end if
  202.           end if
  203.         end if
  204.       end if
  205.     end if
  206.   end if
  207.   if sprite(spriteNum).locH <= 90 then
  208.     if pLightingH <> 3 then
  209.       pLightingH = 3
  210.     end if
  211.   else
  212.     if (sprite(spriteNum).locH > 90) and (sprite(spriteNum).locH <= 170) then
  213.       if pLightingH <> 2 then
  214.         pLightingH = 2
  215.       end if
  216.     else
  217.       if (sprite(spriteNum).locH > 170) and (sprite(spriteNum).locH <= 250) then
  218.         if pLightingH <> 1 then
  219.           pLightingH = 1
  220.         end if
  221.       else
  222.         if (sprite(spriteNum).locH > 250) and (sprite(spriteNum).locH <= 330) then
  223.           if pLightingH <> 0 then
  224.             pLightingH = 0
  225.           end if
  226.         else
  227.           if (sprite(spriteNum).locH > 330) and (sprite(spriteNum).locH <= 410) then
  228.             if pLightingH <> -1 then
  229.               pLightingH = -1
  230.             end if
  231.           else
  232.             if (sprite(spriteNum).locH > 410) and (sprite(spriteNum).locH <= 490) then
  233.               if pLightingH <> -2 then
  234.                 pLightingH = -2
  235.               end if
  236.             else
  237.               if sprite(spriteNum).locH > 490 then
  238.                 if pLightingH <> -3 then
  239.                   pLightingH = -3
  240.                 end if
  241.               end if
  242.             end if
  243.           end if
  244.         end if
  245.       end if
  246.     end if
  247.   end if
  248. end
  249.  
  250. on ObjectCollision
  251.   if sprite(15).intersects(1) then
  252.     pLocH = pLocH - h
  253.     pLocV = pLocV - v
  254.     if gShocked = 0 then
  255.       puppetSound(1, "pop")
  256.       sprite(spriteNum).blend = 40
  257.       gShocked = 1
  258.       pBlink = 25
  259.       gLifePoints = gLifePoints - 1
  260.       sprite(44 + gLifePoints).visible = 0
  261.     end if
  262.   else
  263.     if sprite(15).intersects(35) or sprite(15).intersects(36) then
  264.       if gShocked = 0 then
  265.         puppetSound(1, "pop")
  266.         pLocH = pLocH - h
  267.         pLocV = pLocV - v
  268.         sprite(spriteNum).blend = 40
  269.         gShocked = 1
  270.         pBlink = 25
  271.         gLifePoints = gLifePoints - 1
  272.         sprite(44 + gLifePoints).visible = 0
  273.       end if
  274.     else
  275.       if sprite(15).intersects(22) or sprite(15).intersects(23) or sprite(15).intersects(24) or sprite(15).intersects(25) then
  276.         pLocH = pLocH - h
  277.         pLocV = pLocV - v
  278.       end if
  279.     end if
  280.   end if
  281. end
  282.  
  283. on Check4Win
  284.   if (sprite(spriteNum).locH > 565) and (sprite(spriteNum).locV > 345) then
  285.     member("gameOverText").text = "You Win!!!"
  286.     pBalloonAlive = 0
  287.     gPaused = 1
  288.     if secs < 10 then
  289.       member("TimeLeftText").text = "Elapsed Time:" && string(mins) & ":0" & string(secs)
  290.     else
  291.       member("TimeLeftText").text = "Elapsed Time:" && string(mins) & ":" & string(secs)
  292.     end if
  293.     cursor(-1)
  294.     if soundBusy(5) then
  295.       sound(5).stop()
  296.     end if
  297.     puppetSound(6, "youwin")
  298.     go(20)
  299.   end if
  300. end
  301.